
export default {
	data(){
		return{
			ids: [],
			modal: false,
		}
	},
	created(){
		this.getData();
	},
	methods:{
		handleReset (name) {
			this.$refs[name].resetFields();
		},
		add(){
			
			this.formValidate = this.$options.data().formValidate;
			this.modal = true;
//                对象合并，并且初始表单数据
			delete(this.$data.formValidate._id);
			
		},
		pageChange(page){
			this.filter.page = page;
			this.getData();
		},
		pageSizeChange(pagesize){
			this.filter.rows = pagesize;
			this.getData();
		},
		Search(){
			this.getData()
		},
		//新闻多个删除
		deletes(){
			if(this.ids.length>0){
				this.$Modal.confirm({
					title: '确认删除数据',
					content: '<p>确认删除该数据吗</p>',
					onOk: () => {
						this.$Message.info('删除成功');
						this.$http.post(`http://localhost:3000/${this.module}/deletes`, {ids: this.ids.toString()})
							.then(res => {
								this.getData();
							})
					},
					onCancel: () => {
					}
				});
			}else{
			
			}
		
		},
		show (row) {
//				console.log(row);
			this.modal = true;
			Object.assign(this.$data.formValidate, row);
//				console.log(this.$data.formValidate, row);
		},
		// 表格复选
		onSelectionChange(selections){
			var ids = [];
			if (selections && selections.length > 0) {
				var ids = [];
				let selectionLen = selections.length;
				for (let i = 0; i < selectionLen; i++) {
					ids.push(selections[i]._id);
				}
				this.ids = ids;
			}
		},
	}
}